/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbtest;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

/**
 *
 * @author Paul
 */
public class SidePanel extends JPanel implements ActionListener{
 
    private int gameID;
    private int player1;
    private int player2;
    private int turn;
    JLabel gameLabel;
    JLabel Player1Label;
    JLabel Player2Label;
    JLabel TurnLabel;
    JButton QuitButton;
    JButton HighScores;
    DbConnector DB;
    Game G;
    
    public SidePanel(int GID, int P1, int P2, int T, DbConnector db, Game game){
        G = game;
        gameID = GID;
        player1 = P1;
        player2 = P2;
        turn = T;
        DB = db;
        this.setLayout(new GridLayout(6, 0));
        gameLabel = new JLabel("" + gameID);
        Player1Label = new JLabel("" + player1);
        Player2Label = new JLabel("" + player2);
        TurnLabel = new JLabel ("" + turn);
        HighScores = new JButton("HighScores");
        HighScores.setActionCommand("Show High Scores");
        HighScores.addActionListener(this);
        QuitButton = new JButton("QuitButton"); 
        QuitButton.setActionCommand("Quit");
        QuitButton.addActionListener(this);
        this.add(gameLabel);
        this.add(Player1Label);
        this.add(Player2Label);
        this.add(TurnLabel);
        this.add(HighScores);
        this.add(QuitButton);
        setVisible(true);
    
    }
    
    public void setPlayer1(int i){
    
        player1 = i;
    
    }
    
    public int getPlayer1(){
        
        return player1;
    
    }
    public void setPlayer2(int i){
    
        player2 = i;
    
    }
    
    public int getPlayer2(){
        
        return player2;
    
    }
    
    public void setGameID(int i){
    
        gameID = i;
    
    }
    
    public int getGameID(){
        
        return gameID;
    
    }
    
    public void setTurn(int i){
        
        turn = i;
    
    }
    
    public int getTurn(){
        
        return turn;
    
    }

    @Override
    public void actionPerformed(ActionEvent e){
        
        switch (e.getActionCommand()) {
            case "Quit":
                System.exit(0);
                break;
            case "Show High Scores":
                try{
                G.ShowHighScores();
                System.out.printf("this works");
                } catch(SQLException ex){
                
                }
                break;
        }
    }
}
